<template>
	<view class="content">
		<view class="top-bar">
			<!-- 绝对定位 不站位 -->
			<view class="search">
				<input type="search" placeholder="search"
					placeholder-style="font-size:12rpx;font-weight:400;color:#aaa" @focus="InputFocus" @blur="InputBlur" v-model="searchmsg" />
				<image src="../../static/search.png"></image>
			</view>
			<view class="cancel" >
				<text v-if="searchFocuse">搜索</text>
				<text v-else>取消</text>
			</view>
		</view>
		<view class="main">
			<view class="friends">
				<view class="title">用户</view>
				<view class="friends-list" v-for="(item,index) in friendsList" v-bind:key="index">
					<!-- <image src="../../static/logo.jpg"  mode="widthFix"></image> -->
					<view class="info">
						<navigator url="../user/user?id=aaa" class="top-bar-left">
							<image :src="item.icon"></image>
						</navigator>
						<view class="subInfo">
							<text class="name">{{item.name}}</text>
							<text class="email">{{item.email}}</text>
						</view>
					</view>
					<view class="button">
						发送
					</view>
				</view>
			</view>
			<view class="group">
				<view class="title">群组</view>
				<view class="group-list" v-for="(item,index) in groupList" v-bind:key="index">
					<view class="info">
						<!-- 群组详情 -->
						<navigator url="../user/user?id=aaa" class="top-bar-left">
							<image :src="item.icon"></image>
						</navigator>
						<view class="subInfo">
							<text class="name">{{item.name}}</text>
							<text class="describe">{{item.describe}}</text>
						</view>
					</view>
					<view class="button">
						发送
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
		import datas from "../../common/js-data/test_data.js"
	export default {
		data() {
			return {
				// 取消 还是搜索
				searchFocuse: false,
				friendsList:[],
				groupList:[],
				searchmsg:""
			}
		},
		onLoad() {
			this.searchData()
		},
		methods: {
			searchData(){
				this.getFriendsList();
				this.getGroupList();
			},
			getFriendsList(){
				this.friendsList = datas.getSearchPageFriendsList();
			},
			getGroupList(){
				this.groupList = datas.getSearchPageGroupList();
			},
			InputFocus(){
				this.searchFocuse = true;
			},
			InputBlur(){
				this.searchFocuse = false;
				// 清空input
				this.searchmsg = ""
			}
		}
	}
</script>

<style lang="scss">
	.title {
		padding-left: 10rpx;
		font-size: 44rpx;
		font-weight: 600;
		color: black;
		line-height: 60rpx;
	}

	.main {
		padding-top: env(safe-area-inset-top);
		padding-bottom: env(safe-area-inset-bottom);

		.friends-list {
			padding-top: 18rpx;
			top: 18rpx;
			padding-left: 18rpx;
			justify-content: space-between;
			display: flex;
			align-items: center;

			image {
				height: 96rpx;
				width: 96rpx;
				-webkit-border-radius: $uni-border-radius-base;
				border-radius: $uni-border-radius-base;
				background-color: $uni-color-warning;
			}

			.info {
				display: flex;
				.subInfo {
					display: flex;
					flex-direction: column;
					padding-left: 18rpx;

					.name {
						font-size: 36rpx;
						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						// 文字阴影
						text-shadow: 1px 1px rgba(0, 0, 0, .2);
					}

					.email {
						padding-top: 10rpx;
						font-size: 16rpx;
						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						// 文字阴影
						text-shadow: 1px 1px rgba(0, 0, 0, .2);
					}
				}
			}

			.button {
				margin-right: 40rpx;
				font-size: 6px;
				font-weight: 500;
				color: rgba(51, 51, 51, 1);
				// 文字阴影
				text-shadow: 1px 1px rgba(0, 0, 0, .2);
				background-color: #ffe600;
				background-size: 36rpx;
				border-radius: 24px;
				width: 120rpx;
				height: 55rpx;
				text-align: center;
				line-height: 55rpx;
			}
		}

		.group {
			padding-top: 18rpx;
			top: 50rpx;
		}

		.group-list {
			padding-top: 18rpx;
			top: 50rpx;
			padding-left: 18rpx;
			justify-content: space-between;
			display: flex;
			align-items: center;

			image {
				height: 96rpx;
				width: 96rpx;
				-webkit-border-radius: $uni-border-radius-base;
				border-radius: $uni-border-radius-base;
				background-color: $uni-color-warning;
			}

			.info {
				display: flex;
				.subInfo {
					display: flex;
					flex-direction: column;
					padding-left: 18rpx;
			
					.name {
						font-size: 36rpx;
						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						// 文字阴影
						text-shadow: 1px 1px rgba(0, 0, 0, .2);
					}
			
					.describe {
						padding-top: 10rpx;
						font-size: 16rpx;
						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						// 文字阴影
						text-shadow: 1px 1px rgba(0, 0, 0, .2);
					}
				}
			}

			.button {
				margin-right: 40rpx;
				font-size: 10rpx;
				font-weight: 500;
				color: rgba(51, 51, 51, 1);
				// 文字阴影
				text-shadow: 1px 1px rgba(0, 0, 0, .2);
				background-color: #ffe600;
				background-size: 36rpx;
				border-radius: 20px;
				width: 120rpx;
				height: 55rpx;
				text-align: center;
				line-height: 55rpx;
			}
		}
	}

	.top-bar {
		display: flex;
		/* 固定跟父及无关,只跟页面有关 */
		position: fixed;
		justify-content: space-between;
		align-items: center;
		top: 0;
		left: 0;
		width: 100%;
		height: 108rpx;
		border-bottom: 1px solid #C0C0C0;

		.search {
			display: flex;
			justify-content: space-between;
			align-items: center;
			z-index: -1;
			width: 80%;
			margin-left: 10px;
			box-sizing: border-box;
			background-color: #f6f5ec;
			box-shadow: 0 2px 4px blue($color: #000000);

			image {
				height: 36rpx;
				width: 36rpx;
			}

			input {
				width: 100%;
			}
		}

		.cancel {
			font-size: 36rpx;
			font-weight: 600;
			color: rgba(51, 51, 51, 1);
			// 文字阴影
			text-shadow: 1px 1px rgba(0, 0, 0, .2);
			margin-right: 10px;
		}
	}
</style>
